package socrates.movil;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import socrates.dto.PagoPendienteDTO;
import socrates.ws.WSControler;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Pagos extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);
	  
//	  String [] COUNTRIES = new String[2];
	  List<String> lstelemento = new ArrayList();
	  
	  WSControler con = new WSControler(5); 
	  List<PagoPendienteDTO> lsPagoPendiente = con.obtener_Pago(1);
	  
	  Iterator <PagoPendienteDTO> it = lsPagoPendiente.iterator();
	 // int i=0;
	  DateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
	  
	  while(it.hasNext()){
		  PagoPendienteDTO objPago = it.next();
		  String elemento = objPago.getNroDocumento() +"\nEmision: " +formatter.format(objPago.getFechaEmision())+
				  "\nVencimiento: " + formatter.format(objPago.getFechaVencimiento()) + "\nImporte:" + objPago.getImporte() +" Mora: "+ objPago.getMora() + "\nNro Cuota: "+ objPago.getNroCuota()+ " Descuento: "+ objPago.getDescuento() + "\nSaldo: "+ objPago.getSaldo() + " Total: " + objPago.getTotal();
		 // COUNTRIES[i] = elemento;
		 // i++;
		  lstelemento.add(elemento);
	  }
	  

	  setListAdapter(new ArrayAdapter<String>(this, R.layout.pagos, lstelemento));

	  ListView lv = getListView();
	  lv.setTextFilterEnabled(true);

	 /* lv.setOnItemClickListener(new OnItemClickListener() {
	    public void onItemClick(AdapterView<?> parent, View view,
	        int position, long id) {
	      // When clicked, show a toast with the TextView text
	      Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
	          Toast.LENGTH_SHORT).show();
	    }
	  });*/
	}			
}
